package com.hafu.service;

import com.hafu.model.Course;

import java.sql.SQLException;
import java.util.List;

public class CourseService {
    private CourseDAO courseDAO = new CourseDAO();

    // 获取所有已发布课程
    public List<Course> getPublishedCourses() {
        return courseDAO.getAllPublishedCourses();
    }

    // 教师创建新课程
    public boolean createCourse(String courseId, String courseName, String teacherId) throws SQLException {
        Course course = new Course(courseId, courseName, teacherId);
        return courseDAO.createCourse(course);
    }

    public List<Course> getCoursesByStudentId(String studentId) {
        return courseDAO.getCoursesByStudentId(studentId);
    }

    public boolean deleteCourse(String courseId) {
        return courseDAO.deleteCourse(courseId);
    }

    public boolean auditCourse(String courseId, String auditResult) {
        return courseDAO.auditCourse(courseId, auditResult);
    }

    public List<Course> getAllCourses() {
        return courseDAO.getAllCourses();
    }

    public List<Course> searchCourses(String keyword) {
        return courseDAO.searchCourses(keyword);
    }

    public List<Course> getAvailableCoursesForStudent(String studentId) {
        return courseDAO.getAvailableCoursesForStudent(studentId);
    }

    public List<Course> searchAvailableCoursesForStudent(String studentId, String keyword) {
        return courseDAO.searchAvailableCoursesForStudent(studentId, keyword);
    }
}